package com.oocl.o2o.merchant.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.oocl.o2o.merchant.serializer.UrlSerializer;

@Entity
@GenericGenerator(name = "food_id_generator", strategy = "uuid")
public class Food {
	@Id
	@GeneratedValue(generator = "food_id_generator")
	@Column(columnDefinition = "char(32)")
	private String id;
	private String name;
	private Double price;
	// relative url of image
	@JsonSerialize(using = UrlSerializer.class)
	private String image;
	@ManyToOne
	@JoinColumn(name = "merchant_id", columnDefinition = "char(32)")
	@JsonIgnore
	private Merchant merchant;
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "foot_type_id", columnDefinition = "char(32)")
	// may be it can eager fetch
	private FoodType foodType;

	public Food() {
	}

	public Food(String id, String name, Double price, String image, Merchant merchant, FoodType foodType) {
		this.id = id;
		this.name = name;
		this.price = price;
		this.image = image;
		this.merchant = merchant;
		this.foodType = foodType;
	}

	
	@Override
	public String toString() {
		return "Food [id=" + id + ", name=" + name + ", price=" + price + ", image=" + image + ", merchant=" + merchant
				+ ", foodType=" + foodType + "]";
	}

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public Merchant getMerchant() {
		return merchant;
	}

	public void setMerchant(Merchant merchant) {
		this.merchant = merchant;
	}

	public FoodType getFoodType() {
		return foodType;
	}

	public void setFoodType(FoodType foodType) {
		this.foodType = foodType;
	}

}
